import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate'
import { PERSISTENCE_PREFIX } from '@/constants/cacheEnum'

const pinia = createPinia()

/** 持久化缓存 */
pinia.use(
  createPersistedState({
    key: id => `${PERSISTENCE_PREFIX}-${id}`,
    storage: window.localStorage
  })
)

export default pinia
